//this file is part of eMule
//Copyright (C)2002-2006 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / http://www.emule-project.net )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#pragma once

#define CONFIGFOLDER			_T("config\\")
#define SQLITE3DB					_T("PKMP.s3db")
#define PLUGINS					_T("\\plugins")
#define	SCRIPTS					_T("scripts\\")
#define ATTACHFOLDER			_T("ATTACH\\")

#define SETTING_SECTION_MAIN				_T("Main")

#define SETTING_DF_KNL						_T("Default_Knowledge")
#define SETTING_DF_PSW						_T("Default_Password")
#define SETTING_DF_TBX						_T("Default_Toolbox")
#define SETTING_UPG_A						_T("Auto_Upgrade")
#define SETTING_UPG_Q						_T("Manual_Upgrade")
#define SETTING_PROXY						_T("Use_Proxy")
#define SETTING_AUTOSTART					_T("Auto_Start")

#define SETTING_SECTION_PASSWORD			_T("Passowrd")
#define SETTING_PSW_LOCK_MIN				_T("Lock_When_Min")
#define SETTING_PSW_LOCK_SWITCH				_T("Lock_When_Switch")
#define SETTING_PSW_LOCK_IDLE				_T("Lock_When_Idle")
#define SETTING_PSW_LOCK_TEXT				_T("Idle_Second")
#define SETTING_PSW_CLEAR					_T("Clear_Clipboard")
#define SETTING_PSW_CLEAR_S					_T("Wait_Second")
#define SETTING_PSW_MIN_LEN					_T("Psw_Min_Len")
#define SETTING_PSW_QUAL_LEN				_T("Psw_Qual_Len")
#define SETTING_PSW_GENPROFILE				_T("Genp_Profile")

#define SETTING_SECTION_TOOLBOX				_T("Toolbox")
#define SETTING_TBX_SHOW_MAX				_T("Show_Max")
#define SETTING_TBX_SHOW_MIN				_T("Show_Min")
#define SETTING_TBX_AUTO_HIDE				_T("Auto_Hide")
#define SETTING_TBX_TRANSPARENT				_T("Min_Transparent")
#define SETTING_TBX_TRANS_TEXT				_T("MTransparent_Value")
#define SETTING_TBX_SHOW_FLOATING			_T("Show_Floating")
#define SETTING_TBX_FLOAT_TRS				_T("Floating_Trpa")
#define SETTING_TBX_FLOAT_TRS_TEXT			_T("FTransparent_Value")


#define WM_SETTING_CHANGED					(WM_APP + 1105)

enum EViewSharedFilesAccess{
	vsfaEverybody = 0,
	vsfaFriends = 1,
	vsfaNobody = 2
};

enum ENotifierSoundType{
	ntfstNoSound = 0,
	ntfstSoundFile = 1,
	ntfstSpeech = 2
};

enum EToolbarLabelType;
enum ELogFileFormat;


// deadlake PROXYSUPPORT
struct ProxySettings{
	uint16		type;
	uint16		port;
	CStringA	name;
	CStringA	user;
	CStringA	password;
	bool		EnablePassword;
	bool		UseProxy;
};
struct MainSettings
{
	BOOL		Default_Knowledge;
	BOOL		Default_Password;
	BOOL		Default_Toolbox;
	BOOL		Auto_Upgrade;
	BOOL		Manual_Upgrade;
	BOOL		Use_Proxy;
	BOOL		Auto_Start;
};
struct PasswordSettings
{
	BOOL		Lock_When_Min;
	BOOL		Lock_When_Switch;
	BOOL		Lock_When_Idle;
	int			Idle_Second;
	BOOL		Clear_Clipboard;
	int			Wait_Second;
	int			Psw_Min_Len;
	int			Psw_Qual_Len;
	CString		Genp_Profile;
};
struct ToolBoxSettings
{
	BOOL		Show_Max;
	BOOL		Show_Min;
	BOOL		Auto_Hide;
	BOOL		Min_Transparent;
	int			MTransparent_Value;
	BOOL		Show_Floating;
	BOOL		Floating_Trpa;
	int			FTransparent_Value;
};
struct KnowledgeSettings
{
};

class CPreferences
{
public:
	static	TCHAR	datetimeformat[64];
	static	TCHAR	datetimeformat4log[64];
	static	bool	log2disk;
	static	bool	debug2disk;
	static	int		iMaxLogBuff;
	static	UINT	uMaxLogFileSize;
	static	WORD	m_wLanguageID;
	static	ProxySettings proxy; // deadlake PROXYSUPPORT
	static  bool	showSplash;
	static	bool	newView;
	static MainSettings		m_MainSettings;
	static PasswordSettings	m_PswSettings;
	static ToolBoxSettings		m_TbxSettings;

	CPreferences();
	~CPreferences();

	static	void	Init();
	static	void	Uninit();

	static	const CString& GetAppDir()					{return appdir;}
	static	const CString& GetConfigDir()				{return configdir;}
	static	const CString& GetPluginsDir()				{return m_strPluginDir;}
	static	const CString& GetScriptsDir()				{ return m_strScriptsDir; }
	static	const CString& GetPluginsConfigFile()		{ return m_strPluginsConfigFile;};
	static	const CString& GetAttachDir()				{ return m_strAttachDir; }
	static	LPCTSTR GetConfigFile();
	static  CString& GetDB()						{return m_strDbName;}
	static	const CString& GetLogDir()					{return m_strLogDir;}

	static	bool	IsConfigFile(const CString& rstrDirectory, const CString& rstrName);
	static	bool	IsInstallationDirectory(const CString& rstrDir);

	static	bool	Save();
	static	void	SaveCats();
	static  void  InitDB();
	

	static	WORD	GetLanguageID();
	//static	void	SetLanguageID(WORD lid);
	//static	void	GetLanguages(CWordArray& aLanguageIDs);
	//static	void	SetLanguage();
	static	const CString& GetLangDir()					{return m_strLangDir;}
	static	bool	IsLanguageSupported(LANGID lidSelected, bool bUpdateBefore);
	static	CString GetLangDLLNameByID(LANGID lidSelected);
	static	void	InitThreadLocale();
	static	void	SetRtlLocale(LCID lcid);
	static	CString GetHtmlCharset();
	static	CString GetDateTimeFormat()					{return CString(datetimeformat);}
	static	CString GetDateTimeFormat4Log()				{return CString(datetimeformat4log);}
	static	bool	GetLog2Disk()						{return log2disk;}


protected:
	static	CString appdir;
	static	CString configdir;
	static	CString m_strPluginDir;
	static	CString m_strScriptsDir;
	static	CString m_strAttachDir;
	static	CString m_strWebServerDir;
	static	CString m_strLangDir;
	static	CString m_strFileCommentsFilePath;
	static	CString m_strLogDir;
	static	CString m_strDbName;
	static  CString m_strPluginsConfigFile;
	static	WORD m_wWinVer;
	static void	SetStandartValues();
	static int	GetRecommendedMaxConnections();
	static void LoadPreferences();
	static void SavePreferences();
	static CString GetHomepageBaseURLForLevel(int nLevel);
};

extern CPreferences thePrefs;

